﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using DAL;

public class own : IHttpHandler
{
    OwnDAL OD = new OwnDAL();
    QXHelper QX = new QXHelper();
    public void ProcessRequest(HttpContext context)
    {
        string functionname = context.Request.Form["functionname"].ToString();
        switch (functionname)
        {
            //start记事本部分
            //查询记事本
            case "jhy_note_query": jhy_note_query(); break;
            //记事本添加内容
            case "jhy_note_add": jhy_note_add(); break;
            //记事本修改内容
            case "jhy_note_edit": jhy_note_edit(); break;
            //记事本删除内容
            case "jhy_note_delete": jhy_note_delete(); break;
            //end记事本部分
            //start 代办任务-----------
            //查询代办任务
            case "jhy_task_query": jhy_task_query(); break;
            //查询已完成代办任务
            case "jhy_task_query_done": jhy_task_query_done(); break;
            //添加代办任务
            case "jhy_task_add": jhy_task_add(); break;
            //删除代办任务
            case "jhy_task_delete": jhy_task_delete(); break;
            //修改代办任务
            case "jhy_task_edit": jhy_task_edit(); break;
            //修改代办任务状态
            case "jhy_task_done": jhy_task_done(); break;
            //start 代办任务-----------
            //start 日记本------------
            //查询日记
            case "jhy_diary_query": jhy_diary_query(); break;
            //添加日记
            case "jhy_diary_add": jhy_diary_add(); break;
            //修改日记
            case "jhy_diary_edit": jhy_diary_edit(); break;
            //删除日记
            case "jhy_diary_delete": jhy_diary_delete(); break;
                //end 日记本------------
        }
    }

    //start记事本部分
    #region 查询记事本
    public void jhy_note_query()
    {
        string note_para = HttpContext.Current.Request.Form["note_para"].ToString();
        string laypage = HttpContext.Current.Request.Form["page"].ToString();
        string laylimit = HttpContext.Current.Request.Form["limit"].ToString();
        HttpContext.Current.Response.Write(OD.jhy_note_query(note_para, laypage, laylimit));
    }
    #endregion
    #region 记事本添加内容
    public void jhy_note_add()
    {
        string note_title = HttpContext.Current.Request.Form["note_title"].ToString();
        string note_content = HttpContext.Current.Request.Form["note_content"].ToString();
        bool b = OD.jhy_note_add(note_title, note_content);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 记事本修改内容
    public void jhy_note_edit()
    {
        string note_id = HttpContext.Current.Request.Form["note_id"].ToString();
        string note_title = HttpContext.Current.Request.Form["note_title"].ToString();
        string note_content = HttpContext.Current.Request.Form["note_content"].ToString();
        bool b = OD.jhy_note_edit(note_id, note_title, note_content);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 记事本删除内容
    public void jhy_note_delete()
    {
        string note_id = HttpContext.Current.Request.Form["note_id"].ToString();
        bool b = OD.jhy_note_delete(note_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    //end 记事本部分

    //start 代办任务
    #region 查询代办任务
    public void jhy_task_query()
    {
        HttpContext.Current.Response.Write(OD.jhy_task_query());
    }
    #endregion
    #region 查询已完成代办任务
    public void jhy_task_query_done()
    {
        string laypage = HttpContext.Current.Request.Form["page"].ToString();
        string laylimit = HttpContext.Current.Request.Form["limit"].ToString();
        HttpContext.Current.Response.Write(OD.jhy_task_query_done(laypage, laylimit));
    }
    #endregion
    #region 添加代办任务
    public void jhy_task_add()
    {
        string task_content = HttpContext.Current.Request.Form["task_content"].ToString();
        string task_datetime = HttpContext.Current.Request.Form["task_datetime"].ToString();
        bool b = OD.jhy_task_add(task_content, task_datetime);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 删除代办任务
    public void jhy_task_delete()
    {
        string task_id = HttpContext.Current.Request.Form["task_id"].ToString();
        bool b = OD.jhy_task_delete(task_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 修改代办任务
    public void jhy_task_edit()
    {
        string task_id = HttpContext.Current.Request.Form["task_id"].ToString();
        string task_content = HttpContext.Current.Request.Form["task_content"].ToString();
        string task_datetime = HttpContext.Current.Request.Form["task_datetime"].ToString();
        bool b = OD.jhy_task_edit(task_id, task_content, task_datetime);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 修改代办任务状态
    public void jhy_task_done()
    {
        string task_id = HttpContext.Current.Request.Form["task_id"].ToString();
        bool b = OD.jhy_task_done(task_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    //end 代办任务

    //start 日记本
    #region 查询日记
    public void jhy_diary_query()
    {
        string date_start = HttpContext.Current.Request.Form["date_start"].ToString();
        string date_end = HttpContext.Current.Request.Form["date_end"].ToString();
        string para = HttpContext.Current.Request.Form["para"].ToString();
        HttpContext.Current.Response.Write(OD.jhy_diary_query(date_start, date_end, para));
    }
    #endregion
    #region 添加日记
    public void jhy_diary_add()
    {
        string diary_html = HttpContext.Current.Request.Form["diary_html"].ToString();
        string diary_txt = HttpContext.Current.Request.Form["diary_txt"].ToString();
        bool b = OD.jhy_diary_add(diary_html, diary_txt);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 修改日记
    public void jhy_diary_edit()
    {
        string diary_id = HttpContext.Current.Request.Form["diary_id"].ToString();
        string diary_html = HttpContext.Current.Request.Form["diary_html"].ToString();
        string diary_txt = HttpContext.Current.Request.Form["diary_txt"].ToString();        
        bool b = OD.jhy_diary_edit(diary_id, diary_html, diary_txt);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 删除日记
    public void jhy_diary_delete()
    {
        string diary_id = HttpContext.Current.Request.Form["diary_id"].ToString();
        bool b = OD.jhy_diary_delete(diary_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    //end 日记本




    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}